{% extends "base.html" %}
{% load humanize %}
{% load markup %}

{% block title %}Rep Profile{% endblock %}
{% block head %}
<script type="text/javascript">
  $(function() {
    readMore();
  });
</script>
{% endblock %}

{% block header %}{% endblock %}

{% block primary-content %}
<span class="breadcrumbs"><a href="{% url index %}" title="Home">Home</a> &raquo; <a href="{% url reps %}" title="Reps">Reps</a> &raquo; Profile</span>
  <h2>{{ rep.get_full_name }}{% if rep.candidate_election %} <span>{{ rep.candidate_election }} Candidate for {{ rep.candidate_office }}</span>{% endif %}</h2>
  <div class="rep-snapshot">
    <img width="170" height="204" class="profile-headshot" src="{% if rep.photo %}{{ rep.photo.url }}{% else %}{{ MEDIA_URL }}images/op_blank_thumb.png{% endif %}"/>
    <ul id="rep-info">
      {% if rep.party %}<li>{{ rep.party }}</li>{% endif %}
      <li>{{ rep.primary_address1 }}<br />
      {% if rep.primary_address2 %}{{ rep.primary_address2 }}<br />{% endif %}
      {% if rep.primary_address3 %}{{ rep.primary_address3 }}<br />{% endif %}
      {{ rep.primary_city }}, {{ rep.primary_state }} {{ rep.primary_postal_code }}</li>
      {% if rep.primary_phone1 %}<li>P: {{ rep.primary_phone1 }}</li>{% endif %}
      {% if rep.primary_fax1 %}<li>F: {{ rep.primary_fax1 }}</li>{% endif %}
      {% if rep.email1 %}
      <li><a href="mailto:{{ rep.email1 }}">{{ rep.email1 }}</a></li>
      {% endif %}
      {% if rep.url1 %}<li><a href="{{ rep.url1 }}">{{ rep.last_name }}'s Website</a></li>{% endif %}
    </ul>
  </div>
  <div class="rep-background abbreviated">
    {% if rep.in_office %}<h3>{{ rep.office }}, {{ rep.get_district_name }}</h3>{% endif %}
    {% if donations %}
    <table id="top-donors">
      <caption>{{ rep.last_name }}'s Top Donors, {{ rep.donor_years }}</caption>
      {% for donation in donations %}
      <tr class="{% cycle 'odd' 'even' %}">
        <th>{{ forloop.counter }}</th>
        <td class="donor">{{ donation.donor.name }}</td>
        <td>${{ donation.amount|intcomma }}</td>
      </tr>
      {% endfor %}
    </table>
    <h4>About {{ rep.last_name }}'s Top Donors</h4>
		{% for donation in donations %}
    <h5>{{ donation.donor.name }}</h5>
    {{ donation.donor.description|markdown }}
    {% endfor %}
    {% endif %}
  </div>
  {% if news %}
  <div id="news-feed">
    <ul id="feed-filters">
      <li><a {% ifequal current "all" %}class="current" {% endifequal %}href="{% url reps_profile rep.id %}">All related news</a></li>
      <li><a {% ifequal current "reports" %}class="current" {% endifequal %}href="{% url reps_profile rep.id %}?r=1">Just related reports</a></li>
      <li><a {% ifequal current "posts" %}class="current" {% endifequal %}href="{% url reps_profile rep.id %}?p=1">Just related blog posts</a></li>
    </ul>
    {% for item in news %}
    <div class="{% if item.is_report %}feed-report{% else %}feed-blog-post{% endif %}">
      <h3><a href="{% if item.is_report %}{% url report item.id %}{% else %}{% url blog_post item.id %}{% endif %}">{{ item.title }}</a></h3>
      <small class="date-posted">Posted {{ item.pub_date|date }}</small>
      {% if item.is_report %}
        {{ item.synopsis|markdown|truncatewords_html:"50" }}
      {% else %}
        {{ item.body|markdown|truncatewords_html:"50" }}
      {% endif %}
      <p class="read-more"><a href="{% if item.is_report %}{% url report item.id %}{% else %}{% url blog_post item.id %}{% endif %}">Read more &raquo;</a></p>
    </div>
    {% endfor %}
  </div>
  {% endif %}
{% endblock %}

